A good answer might be:

No. A constructor is used once per object. Once an object has been created the constructor is finished.

Dot Notation

After an object has been constructed it can (usually) be changed by using its own methods (not its constructor.) Some objects are designed so that once they have been constructed they cannot be changed at all.

The two types of things inside of an object—variables and methods—are sometimes called members of that object. The members of an object are accessed using dot notation. The example program creates a String object, referred to by the variable str1.


    String str1;   // str1 is a reference to an object.
    int    len;    
    str1 = new String("Random Jottings");  // create an object of type String
                                                           
    len  = str1.length();  // invoke the object's method length()

The length() method is a member of str1. To refer to this method of the object str1 put the two together with a dot:

len  = str1.length();  

The above is an assignment statement and, as always, does its work in two steps:

  1. The expression on the right of the "=" is evaluated.
  2. The resulting value is stored in the variable on the left of the "=" sign.

The right-hand side of this particular assignment statement executes the method length() which is member of str1. Executing this member method returns the number of characters in the object.

QUESTION 15:

Do you think that the following is correct?

str1.length() = 12 ;  // change the length of str1